package com.phoenix;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.security.Principal;

/**
 * Created by lilongfei on 16/6/8.
 */
@RestController
@RequestMapping("/test")
public class TestController {


    @PreAuthorize("hasRole('USER')")
    @RequestMapping("/hello")
    public Principal test(Principal principal){
        return principal;
    }

    @PreAuthorize("#oauth.isAnonymous()")
    @RequestMapping("/test")
    public String hello(){
        return "world";
    }
}
